package com.yafengliang.springboot.controller;

import com.yafengliang.springboot.model.User;
import com.yafengliang.springboot.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.util.HtmlUtils;

import java.util.Objects;

/**
 * @author yafengliang@yeah.net
 * @Description
 * @date 2021/4/21 18:05
 */
@Controller
@Slf4j
public class LoginController {

    @CrossOrigin
    @PostMapping(value = "/api/login")
    @ResponseBody
    public Result login(@RequestBody User user){
        String username = user.getUsername();
        username = HtmlUtils.htmlEscape(username);
        if (!Objects.equals("admin",username) || !Objects.equals("123456",user.getPassword())){
            String message = "username or password was wrong!";
            log.info("test");
        }else {
            return new Result(200);
        }
        return null;
    }

}
